﻿@using Smartstore.Core.Catalog.Attributes

@model AddOrderProductModel

<div id="AddProductAttributeContainer" class="adminContent">
    @foreach (var attribute in Model.ProductVariantAttributes)
    {
        var controlId = attribute.BuildControlId();
        <div class="adminRow">
            <div class="adminTitle">
                <div class="ctl-label">
                    <label for="PriceExclTax">
                        @(attribute.TextPrompt.NullEmpty() ?? attribute.Name)
                    </label>
                </div>
            </div>
            <div class="adminData">
                @switch (attribute.AttributeControlType)
                {
                    case AttributeControlType.DropdownList:
                        {
                            <select name="@controlId" id="@controlId">
                                <option sm-if="!attribute.IsRequired" value="0">---</option>
                                @foreach (var value in attribute.Values)
                                {
                                    <option attr-selected='(value.IsPreSelected, "selected")' value="@value.Id">@value.Name</option>
                                }
                            </select>
                        }
                        break;
                    case AttributeControlType.RadioList:
                    case AttributeControlType.Boxes:
                    case AttributeControlType.Checkboxes:
                        {
                            foreach (var value in attribute.Values)
                            {
                                var checkId = controlId + "_" + value.Id;
                                <div class="form-check">
                                    <input id="@checkId" name="@controlId" class="form-check-input"
                                           attr-checked='(value.IsPreSelected, "checked")'
                                           type="@(attribute.AttributeControlType == AttributeControlType.Checkboxes ? "checkbox" : "radio")"
                                           value="@value.Id" />
                                    <label for="@checkId" class="form-check-label">@value.Name</label>
                                </div>
                            }
                        }
                        break;
                    case AttributeControlType.TextBox:
                        {
                            <input name="@controlId" type="text" id="@controlId" class="form-control" />
                        }
                        break;
                    case AttributeControlType.MultilineTextbox:
                        {
                            <textarea id="@controlId" name="@controlId" rows="6" class="form-control"></textarea>
                        }
                        break;
                    case AttributeControlType.Datepicker:
                        {
                            <input type="date"
                                   name="@(controlId)-date" id="@(controlId)-date"
                                   class="native-validation form-control"
                                   min="@DateTime.Now.ToString("yyyy-MM-dd")"
                                   max="@DateTime.Now.AddYears(1).ToString("yyyy-MM-dd")" />
                        }
                        break;
                    case AttributeControlType.FileUpload:
                        {
                            <input type="file" id="@controlId" name="@controlId" />
                        }
                        break;
                }
            </div>
        </div>
    }
</div>